Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath({'Ext.ux' : 'extjs4/ux'});
Ext.require([
             'Ext.grid.*',
             'Ext.data.*',
             'Ext.ux.grid.FiltersFeature',
             'Ext.toolbar.Paging',
             'Ext.ux.ajax.JsonSimlet',
             'Ext.ux.ajax.SimManager',
             'Ext.ux.grid.Printer'
]);
Ext.define('TS.view.rp.RpARecCheckList',{
	extend:'Ext.panel.Panel',
	border: false,
	bodyPadding:0,
	layout: 'border',
	alias: 'widget.rparecchecklist',
	title: '应收款核销查询',
	initComponent:function() {
		this.items = [
		    {
		    	xtype: 'form',
		    	title: '检索',
		    	region: 'north',
		    	height: 100,
		    	collapsible: true,
		    	border: false,
		    	buttonAlign: 'left',
		    	header: {iconCls: 'bill-search-button'},
		    	layout: 'hbox',
		    	fieldDefaults:{
		    		labelStyle:'text-align:right',
		    		margin:'10 10 10 10',
		    	},
		    	items:[
			    	    {xtype: 'hiddenfield',name:'custId',value:this.custId},
			    	    {
			    	    	xtype:'datefield',name:'begDate',fieldLabel:'开始日期',value:new Date(),format:'Y-m-d'
			    	    },
			    	    {
			    	    	xtype:'datefield',name:'endDate',fieldLabel:'截止日期',value:new Date(),format:'Y-m-d'
			    	    },
			    	    {
			    	    	xtype: 'triggerfield',
			    	    	name:'customer',
			    	    	fieldLabel:'客户:',
			    	    	width:400,
			    	    	value:this.custName,
			    	    	emptyText:'请输入客户编码或名称',trigger1Cls:Ext.baseCSSPrefix + 'form-search-trigger',
			    	    	onTriggerClick:function(e){e.keyCode=e.ENTER;this.fireEvent('specialkey',this,e);}
			    	    },		    	    
			    	    {xtype: 'button',text:'查询',margin:'10 10 10 10',action:'search',iconCls:'bill-find-button'},
			    	    {xtype: 'button',text:'高级检索',margin:'10,10,10,10',action:'advsearch',iconCls:'bill-search-button'}
		    	]
		    },
    	    {
				xtype:'gridpanel',
				header:false,
				border:false,
				region:'center',
				store:'rp.ARecCheckLogStore',
			    features: [{
			        ftype: 'summary'
			    },{
			    	ftype: 'filters',
			    	encode: false,
			    	local: true,
			    	filters: [{
			            type: 'int',
			            dataIndex: 'checkId'
			        }]
			    }],
				columns:[
						   {header:'核销号',dataIndex:'checkId',filterable:true,width:50},
						   {header:'核销日期',dataIndex:'checkDate',width:80,renderer:Ext.util.Format.dateRenderer('Y-m-d')},
						   {header:'核销类型',dataIndex:'checkTypeName'},
						   {header:'核销人',dataIndex:'checker',width:60,renderer:function(value,metaData,record){if(record.checkerHasOneInstance) { return record.getchecker().get('empName');}}},
						   {header:'客商编码',width:65,renderer:function(value,metaData,record){return record.getcustomer().get('customerCode');}},
						   {header:'客商名称',width:230,renderer:function(value,metaData,record){return record.getcustomer().get('customerName');}},
						   {header:'应收单',dataIndex:'arpBillCode',width:100},
						   {header:'收款单',dataIndex:'rpBillCode',width:100},
						   {header:'借方金额',dataIndex:'debitAmt',width:80,align:'right',summaryType:'sum',summaryRenderer:function(value,summaryData,dataIndex){return '<b>' + Ext.util.Format.number(value,'0,000.00') + '</b>';},renderer : Ext.util.Format.numberRenderer('0.00')},
						   {header:'贷方金额',dataIndex:'creditAmt',width:80,align:'right',summaryType:'sum',summaryRenderer:function(value,summaryData,dataIndex){return '<b>' + Ext.util.Format.number(value,'0,000.00') + '</b>';},renderer : Ext.util.Format.numberRenderer('0.00')},
						   {header:'转销单',dataIndex:'transferBillCode',width:100},
						   {header:'转销客商',dataIndex:'transferCust',width:100},
						   {header:'备注',dataIndex:'remark',width:100}
				],
				dockedItems:[{
					xtype:'pagingtoolbar',
					store:'rp.ARecCheckLogStore',
					dock:'bottom',
					displayInfo:true,
					items:[{
						text:'清除过滤条件',
						iconCls:'button-clear-filter',
						handler:function(){
							var grid = this.up('gridpanel');
							grid.filters.clearFilters();
						}
					},{
						xtype:'exporterbutton',
						component:this.up('gridpanel'),
						text:'导出 Excel',
						iconCls:'bill-export-button'
					},{
						text:'<font color="red">【应收款转销】反核销后需要手工删除对应的收款单与应收单！</font>',
					}]
				}],
				tbar:[
						{xtype:'button',text:'核销',action:'check',iconCls:'button-rp-check'},
						{xtype:'button',text:'反核销',action:'unCheck',iconCls:'button-rp-uncheck'},
						{xtype:'button',text:'打印',action:'printBill',iconCls:'bill-printer-button'},
						{xtype:'button',text:'导出',action:'exportBill',iconCls:'bill-export-button'}
				]			    				
    	    }		    
		];
		this.callParent(arguments);
	}
});